import {defHttp} from '/@/utils/http/axios';
import { Modal } from "ant-design-vue";

export enum Api {
  bankById = "/bank/queryById",
  bankSave = "/bank/save",
  bankList = "/bank/list",
  bankTransfer = "/bank/transfer",

  bankRunningSave = '/bankRunning/save',
  bankRunninglist = '/bankRunning/list',
  bankRunningById = '/bankRunning/queryById',
  bankRunningdelete = '/bankRunning/delete',

  //导入导出
  exportXls = '/bankRunning/exportXls',
  importXls = '/bankRunning/importExcel',

  //支出流水
  bankBalancelist = '/bankBalance/list',
}

/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importXls;

/**
 * 银行账号 - 列表
 * @param params
 */
export const bankList = (params) => defHttp.get({url: Api.bankList, params});

/**
 * 银行账号 - 通过ID获取数据
 * @param params
 */
export const bankById = (params) => defHttp.get({url: Api.bankById, params});

/**
 * 银行账号 - 保存或者更新
 * @param params
 */
export const bankSave = (params) => {
  return defHttp.post({url: Api.bankSave, params}, {isTransformResponse:false});
}

/**
 * 银行账号 - 银行划转
 * @param params
 */
export const bankTransfer = (params) => {
  return defHttp.post({url: Api.bankTransfer, params}, {isTransformResponse:false});
}

/**
 * 银行流水 - 列表
 * @param params
 */
export const bankRunninglist = (params) => defHttp.get({url: Api.bankRunninglist, params});

/**
 * 银行流水 - 保存或者更新
 * @param params
 */
export const bankRunningSave = (params) => {
  return defHttp.post({url: Api.bankRunningSave, params}, {isTransformResponse:false});
}

/**
 * 银行流水 - 通过ID获取数据
 * @param params
 */
export const bankRunningById = (params) => defHttp.get({url: Api.bankRunningById, params});

/**
 * 银行流水 - 通过ID删除数据
 * @param params
 */
export const deleteBankRunning = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.bankRunningdelete, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
}

/**
 * 支出流水 - 列表
 * @param params
 */
 export const bankBalancelist = (params) => defHttp.get({url: Api.bankBalancelist, params});
